<template>
  <el-container class="main_container">
    <el-header class="main_header">
      <MainHeader />
    </el-header>
    <el-container class="main_content">
      <el-aside class="main_aside">
        <Menu />
      </el-aside>
      <el-main class="main_primary">
        <Tags />
        <el-breadcrumb class="coutom_bread" separator="/">
          <img class="location" src="../assets/location.jpg" alt="" />
          <span style="margin-right: 10px;">当前位置 :</span>
          <el-breadcrumb-item
            v-for="item of breadcrumbList"
            :key="item.path"
            :to="{ path: item.path }"
            >{{ item.name }}</el-breadcrumb-item
          >
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
    <el-footer class="main_footer">
      <div class="version">系统版本v1.0</div>
    </el-footer>
  </el-container>
</template>

<script>
import MainHeader from '@/components/header.vue';
import Menu from '@/components/menu.vue';
import Tags from '@/components/tags.vue';
export default {
  components: { MainHeader, Menu, Tags },
  data() {
    return {
      breadcrumbList: [],
    };
  },
  watch: {
    $route(to) {
      this.initBreadcrumbData(to);
    },
  },
  created() {
    this.initBreadcrumbData(this.$route);
  },
  methods: {
    initBreadcrumbData(router) {
      const breadcrumbList = [
        // { path: '/', name: '后台管理系统' } // 是否统一默认一个
      ];
      router.matched.forEach(item => {
        if (item.meta.name) {
          breadcrumbList.push({ path: item.path, name: item.meta.name });
        }
      });
      this.breadcrumbList = breadcrumbList;
    },
  },
};
</script>

<style lang="less" scoped>
.main_container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to right, #0065ba, #004179);
  min-width: 1300px;
  transform: translate(0);
}

.main_header {
  z-index: 2;
  height: 60px !important;
  padding: 0 !important;
}

.main_content {
  flex: 1;
  overflow-y: auto;
}

.main_aside {
  width: auto !important;
  z-index: 2;
  // width: 230px !important;
  // width: 230px !important;
  // background-color: #545c64;
  background-color: #fff;
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;

  &::-webkit-scrollbar {
    display: none;
  }
}

.main_primary {
  padding: 0;
  background-color: #f3f3f3;
  display: flex;
  flex-direction: column;
  margin-left: 16px;
  margin-right: 16px;
  border-radius: 12px;

  /deep/.coutom_bread {
    z-index: 2;
    height: 50px;
    background-color: #ffffff;
    box-sizing: border-box;
    padding-left: 1.5em;
    display: flex;
    align-items: center;
    color: #999999;

    .location {
      margin-right: 10px;
      width: 16px;
    }

    .el-breadcrumb__inner {
      color: #999999;
      font-weight: normal;
    }
  }
}

.main_footer {
  height: 30px !important;
  line-height: 30px;

  .version {
    text-align: right;
    color: #fff;
    font-size: 12px;
  }
}
</style>
